package edu.nanyang.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import edu.nanyang.dao.PaperInfoDao;
import edu.nanyang.domain.PaperInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class PaperInfoService {
    @Resource
    private PaperInfoDao paperInfoDao;

    /**
     * 分页查询
     *
     * @param page     当前页数
     * @param pageSize 每页个数
     * @return
     */
    public PageInfo<PaperInfo> search(int page, int pageSize) {
        PageHelper.startPage(page, pageSize);//改写语句实现分页查询
        List<PaperInfo> all = paperInfoDao.findAll();
        PageInfo<PaperInfo> info = new PageInfo<>(all);
        return info;
    }
    public  List<PaperInfo> findAll(){
        return paperInfoDao.findAll();
    }

    public PaperInfo getByQuestionNumId(Integer questionNumId){
        return paperInfoDao.getByQuestionNumId(questionNumId);
    }

    public PaperInfo getById(int id) {
        return paperInfoDao.getById(id);
    }

    public int deleteById(int id) {
        return paperInfoDao.deleteById(id);
    }

    public int add(PaperInfo paperInfo) {
        return paperInfoDao.add(paperInfo);
    }

    public int update(PaperInfo paperInfo) {
        return paperInfoDao.update(paperInfo);
    }

}
